﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CourseLayoutDetail.aspx.cs"
    Inherits="ZX.WebApp.Crm.MeetingArrange.CourseLayoutDetail" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .input
        {
            width: 45px;
        }
    </style>
    <link href="../../Styles/default/calendar.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/reset-fonts-grids/reset-fonts-grids.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/menu/assets/skins/sam/menu.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <!--end custom header content for this example-->
    <!-- Dependencies -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <!-- OPTIONAL: Connection Manager (enables XHR for DataSource) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <!-- OPTIONAL: Get Utility (enables dynamic script nodes for DataSource) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <!-- OPTIONAL: Drag Drop (enables resizeable or reorderable columns) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <!-- Source files -->
    <script src="../../Scripts/yui_2.9.0/build/datatable/datatable.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/resize/resize-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.calendar.js" type="text/javascript"></script>
    <script src="../../Scripts/common.js" type="text/javascript"></script>
    <script src="../../Scripts/Appjs/jquery.CheckData.js" type="text/javascript"></script>
</head>
<body class="yui-skin-sam">
    <form id="form1" runat="server">
    <div id="toolbar" style="margin-top: 3px;">
        <button type="button" id="btnSave" name="btnSave">
            保存</button>
        <button type="button" id="btnClose" name="btnClose">
            退出</button>
    </div>
    <div class="fieldForm" id="fieldForm">
        <table id="CourseLayoutTable" width="50%" cellpadding="0" cellspacing="0" border="0.5px"
            style="line-height: 30px">
            <tr>
                <td>
                    &nbsp 产品名称:
                </td>
                <td>
                    <input id="txtProductName" readonly="readonly" style="background-color: #CCCCCC"
                        value='<%=ProductName %>' />
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp  规划名称:<font color='red'>*</font>
                </td>
                <td>
                    <input id="txtCourseLayoutName" name="CourseLayoutName" requiretype="1" />
                </td>
                <td>
                    <font color='#CCCCCC' font-size='10px'>课程规划名称不能为空</font>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp  开始时间:<font color='red'>*</font>
                </td>
                <td>
                    <input id="txtBeginDate" name="BeginDate" class="datetime" readonly="readonly" requiretype="1" />
                </td>
            </tr>
            <tr>
                <td>
                     &nbsp 结束时间:<font color='red'>*</font>
                </td>
                <td>
                    <input id="txtEndDate" name="EndDate" class="datetime" readonly="readonly" requiretype="1">
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp  地点:<font color='red'>*</font>
                </td>
                <td class="input">
                    <input id="txtPlace" name="Place" requiretype="1" />
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp  备注:
                </td>
                <td colspan="2">
                    <textarea id="txtRemark" name="Remark" cols="30" rows="5"></textarea>
                </td>
            </tr>
        </table>
    </div>
    <div class="tab" id="fieldTab">
        <div id="toolbar2" style="margin: 2px;">
            <button type="button" id="btnNew" name="btnNew">
                新增</button>
            <button type="button" id="btnDelete" name="btnDelete">
                删除</button>
        </div>
        <div id="json">
        </div>
    </div>
    <div id="dialog1" class="yui-pe-content">
        <div class="hd">
            新增产品规划角色</div>
        <div class="bd">
            <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
         <div id="dialog2" class="yui-pe-content">
        <div class="hd">
            选择用户</div>
        <div class="bd">
            <iframe id="EditUIWindow2" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
        <div id="dialog3" class="yui-pe-content"  >
        <div class="hd">
            提示</div>
        <div class="bd">
            你正在删除当前选择的数据，继续请按确定？
        </div>
    </div>
    </form>
</body>
<script src="../../Scripts/CreateCommonDataList.js" type="text/javascript"></script>
<script type="text/javascript">
    var const_entityID = "<% =EntityId %>",    //实体ID名称
        const_entityName ='V_CrmProductLayout',//实体名称
        const_DataFields = [<% =DataFields %>],
        const_DataColums = [<% =DataColums %>],
        selectControl=null,
        requireUrl="",
        initialRequestUrl = "pageindex=1&entity=" + const_entityName +"&r="+Math.random()+"&zip=94089&results=10&output=json&condition=ID='<%=Guid.Empty %>'",
        SaveUrl,dl;//要删除的数据列  

        var flag="False";
     <asp:Literal ID="EditTemplate" runat="server"></asp:Literal>
       if('<%=isEdit%>'=="True")
      {
        flag="True";
         $("#CourseLayoutTable").JSONToForm($.toJSON(instance[0]));
         initialRequestUrl = "pageindex=1&entity=" + const_entityName +"&r="+Math.random()+"&zip=94089&results=10&output=json&condition=ProductRoleID<>'00000000-0000-0000-0000-000000000000' and "+"ProductLayoutId='"+getPar1("id")+"'";
         BindData();
     }
        YAHOO.namespace("example.container");
     //设置页面布局
      (function () {
        var Dom = YAHOO.util.Dom,
            Event = YAHOO.util.Event;
            Event.onDOMReady(function () {
            var layout = new YAHOO.widget.Layout({
                units: [
                    { position: 'top', height: 35, body: 'toolbar', gutter: '0 0 0 0', scroll: null, zIndex: 2 },
                    { position: 'center', body: 'fieldForm', gutter: '0 0 0 0', scroll: true },
                    { position: 'bottom', height: 300, body: 'fieldTab', gutter: '0 0 0 0', scroll: true, resize: true}
                    ]
            });
            layout.render();
        });
        BindData();
        initWindow();
    })();

    
        YAHOO.util.Event.onContentReady("toolbar", function () {
        var btnSave = new YAHOO.widget.Button("btnSave");
        btnSave.on("click", Save);
        var btnClose = new YAHOO.widget.Button("btnClose");
        btnClose.on("click", close);
         var btnNew = new YAHOO.widget.Button("btnNew");
        btnNew.on("click", create);
         var btnDelete = new YAHOO.widget.Button("btnDelete");
        btnDelete.on("click", Delete);
        });
       //为json对象赋值
       function setValue()
        {
          
             $("#CourseLayoutTable").SetFormValueToObject(instance[0]);
             if("<%=isEdit%>"=="False")
             {
                 instance[0].ProductID=getPar1("productId");
                 instance[0].ID="<%=Guid.NewGuid() %>";
             }
        }
        
       //保存方法

       function Save()
       {
            //1：执行客户端验证
             if($("#CourseLayoutTable").checkInputData()==1)
              {
                if(checkBeginDateAndEndDate("txtBeginDate","txtEndDate"))
                {
                    //2:赋值
                    setValue();
                    //3:保存或更新
                    var url = "../../Extend/AjaxData/DataSave.aspx";
                    var json =decodeURI($.toJSON(instance[0]));
                    if("<%=isEdit%>"=="False")
                    {
                        $("#CompanyTable").SaveData(url,"CrmProductLayout",json,"insert");
                   
                    
                    }
                    else
                    {
                        $("#CompanyTable").SaveData(url,"CrmProductLayout",json,"update");
                    }
                    alert('保存成功');
                     flag="True";//标枳已保存过产品规划
                     return true;
                 }
             
              }
               else
                 {
                   alert("你填写的资料未通过格式验证");
                   return false;
                 }
       }

       function initWindow()
       {
             // Define various event handlers for Dialog
           var handleSubmit = function () {
                var editwindow = document.getElementById("EditUIWindow1");
                if (editwindow) {
                    editwindow.contentWindow.Save();
                }
                this.cancel();
                 initialRequestUrl = "pageindex=1&entity=V_CrmProductLayout&r="+Math.random()+"&zip=94089&results=10&output=json&condition="+"ProductLayoutId='"+instance[0].ID+"'";
                 RefreshData();
              };

          var handleCancel = function () {
                this.cancel();
            };

          var handleSubmit1 = function () {
                    var editwindow = document.getElementById("EditUIWindow2");
                    if (editwindow) {
                        editwindow.contentWindow.ChooseInfo();
                    }
                    this.cancel();
                //YAHOO.example.container.dialog2.hide();
            }

         // Remove progressively enhanced content class, just before creating the module
                YAHOO.util.Dom.removeClass("dialog1", "yui-pe-content");

    /*
    数据编辑
    */
  

      YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
							    { width: "500px",
							        height: "300px",
							        fixedcenter: true,
							        visible: false,
							        draggable: true,
							        close: true,
							        autofillheight: "body",
							        constraintoviewport: true,
							        buttons: [{ text: "保存", handler: handleSubmit, isDefault: true },
								          { text: "取消", handler: handleCancel}]
							    });
       YAHOO.example.container.dialog1.render();

        YAHOO.example.container.dialog2 = new YAHOO.widget.Dialog("dialog2",
							    { width: "500px",
							        height: "500px",
							        fixedcenter: true,
							        visible: false,
							        draggable: true,
							        close: true,
                                    autofillheight: "body",
							        constraintoviewport: true,
							        buttons: [{ text: "保存", handler: handleSubmit1, isDefault: true },
								          { text: "取消", handler: handleCancel}]
							    });
       YAHOO.example.container.dialog2.render();
        YAHOO.example.container.dialog3 = new YAHOO.widget.Dialog("dialog3",
							    {   width: "350px",
							        height: "100px",
							        fixedcenter: true,
							        visible: false,
							        draggable: true,
							        close: true,
							        autofillheight: "body",
							        constraintoviewport: true,
							        buttons: [{ text: "确定", handler: DeleteData, isDefault: true },
								          { text: "取消", handler: handleCancel}]
							    });

       YAHOO.example.container.dialog3.render();
       }

       //新增产品规划角色
       function create()
       { 
           if(flag=="True")
           {
              document.getElementById("EditUIWindow1").src="AddProductLayoutRole.aspx?LayoutId="+instance[0].ID;
              YAHOO.example.container.dialog1.show();
           }
           else
           {
                alert("请先保存产品规划");
           }
      
       }

     //新增产品规划角色
       function Delete()
       { 
             fnDelete("CrmProductLayoutRole");
       }

       /* 对应的方法和ID*/
        var _fn, _id;
        function ShowDialog(fn, id) {
            _fn = fn;
            _id = id;
            YAHOO.example.container.dialog1.show();
        }
        function ShowDialog1(fn, id) {
            _fn = fn;
            _id = id;
            YAHOO.example.container.dialog2.show();
        }
       //关闭
       function close()
       {
              window.parent.$("#tabs").tabs('close', '<%=PageTitle %>');
       }

</script>
</html>
